"""
    图书比价
"""

from spider_dangdang import spider as dangdang
from spider_jingdong import spider as jingdong
from spider_yihaodian import spider as yihaodian

def main(SN):

    # 创建空数组
    book_list = []

    # 当当网的数据
    print('当当网数据爬取完成')
    dangdang(SN, book_list)

    # 京东网的数据
    print('京东网数据爬取完成')
    jingdong(SN, book_list)

    # 一号店的数据
    print('一号店数据爬取完成')
    yihaodian(SN, book_list)

    # 打印所有数据列表
    for book in book_list:
        print(book)

    print('----------开始排序----------')

    # 排序书的数据
    book_list = sorted(book_list, key=lambda item: float(item["price"]), reverse=True)

    for book in book_list:
        print(book)

if __name__ == '__main__':
    SN = input('请输入ISBN: ')
    main(SN)